<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Cache-Control" content="No-Cache">
	<meta http-equiv="Pragma" content="No-Cache">

	<title>운세의 신</title>

	<link rel="stylesheet" type="text/css" href="/css/common.css">
	
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	<script src="/js/common_basic.js"></script>
	<script src="/js/utility/common_util.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#keyword").focus();
			
			// 테이블의 행 클릭시 수정할 정보 셋팅
			var frmModify = $("#frmModify");
			$("#programList tbody tr").each(function(index) {
				$(this).click(function() {
					var td = $(this).find("td");
					frmModify.find("input[name='program_id']").val(td.eq(0).text());
					frmModify.find("input[name='program_name']").val(td.eq(1).text());
					frmModify.find("select[name='type']").val(td.eq(2).text());
					frmModify.find("input[name='priority']").val(td.eq(3).text());
					frmModify.find("input[name='story']").val(td.eq(4).find("input[name='story']").val());
					frmModify.find("input[name='start_dt']").val(td.eq(5).text());
					frmModify.find("input[name='end_dt']").val(td.eq(6).text());
					frmModify.find("input[name='photo_url']").val(td.eq(7).text());
					frmModify.find("select[name='use_yn']").val(td.eq(8).text());
				});
			});
		});
	
		function modify(program_id) {
			var frm = $("#frmModify");
			frm.find("input[name='program_id']").val(program_id);
			frm.find("input[name='program_name']").val(program_id);
		}
	
		function remove(program_id) {
			if (confirm('삭제?')) {
				document.frm2.program_id.value = program_id;
				document.frm2.submit();
			}
		}
	</script>
</head>
<body>

<form method="post" name="frm2" id="frm2" action="/imbc/artist/program_remove_ok">
	<input type="hidden" name="program_id" />
</form>
<div id="wrap">
	<!-- Header -->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/header.php'; ?>
	<!--// Header -->
	
	<!-- Contents -->
	<div id="content">
		<h2>iMBC 프로그램 관리 - 리스트</h2>
		<div>
			<table id="programList" class="basicTable" width="100%" cellpadding="2" cellspacing="1" border="0">
				<thead>
					<tr>
						<th>프로그램ID</th>
						<th>프로그램명</th>
						<th>프로그램종류(장르)</th>
						<th>정렬순위</th>
						<th>줄거리</th>
						<th>방송시작일</th>
						<th>방송종료일</th>
						<th>포스터URL</th>
						<th>노출여부</th>
						<th>삭제</th>
					</tr>
				</thead>
				<tbody>
<?	foreach ($program_list as $item) : ?>
					<tr>
						<td align="center"><?=$item['program_id']?></td>
						<td align="center"><?=$item['program_name']?></td>
						<td align="center"><?=$item['type']?></td>
						<td align="center"><?=$item['priority']?></td>
						<td align="center"><?=mb_substr($item['story'], 0, 20, 'utf-8')?>...<input type="hidden" name="story" value="<?=$item['story']?>"/></td>
						<td align="center"><?=$item['start_dt']?></td>
						<td align="center"><?=$item['end_dt']?></td>
						<td align="center"><?=$item['photo_url']?></td>
						<td align="center"><?=$item['use_yn']?></td>
						<td align="center"><button onclick="remove('<?=$item['program_id']?>')">삭제</button></td>
					</tr>
<?	endforeach ?>
				</tbody>
			</table>
		</div>

		<h2>iMBC 프로그램 등록</h2>
		<div>
			<form id="frm" method="post" action="/imbc/artist/program_register_ok">
				<fieldset>
					<table class="basicTable" width="100%" cellpadding="2" cellspacing="1" border="0">
						<thead>
							<tr>
								<th>프로그램ID</th>
								<th>프로그램명</th>
								<th>프로그램종류(장르)</th>
								<th>정렬순위</th>
								<th>줄거리</th>
								<th>방송시작일</th>
								<th>방송종료일</th>
								<th>포스터URL</th>
							</tr>
						</thead>
						<tr>
							<td align="center"><input type="text" name="program_id" /></td>
							<td align="center"><input type="text" name="program_name" /></td>
							<td align="center">
								<select name="type">
									<option value="드라마">드라마</option>
									<option value="예능">예능</option>
								</select>								
							</td>
							<td align="center"><input type="text" name="priority" /></td>
							<td align="center"><input type="text" name="story" /></td>
							<td align="center"><input type="text" name="start_dt" /></td>
							<td align="center"><input type="text" name="end_dt" /></td>
							<td align="center"><input type="text" name="photo_url" /></td>
						</tr>
					</table>
					<input type="submit" value="입력완료" />
				</fieldset>
			</form>	
		</div>

		<h2>iMBC 프로그램 수정</h2>
		<div>
			<form id="frmModify" method="post" action="/imbc/artist/program_modify_ok">
				<fieldset>
					<table class="basicTable" width="100%" cellpadding="2" cellspacing="1" border="0">
						<thead>
							<tr>
								<th>프로그램ID</th>
								<th>프로그램명</th>
								<th>프로그램종류(장르)</th>
								<th>정렬순위</th>
								<th>줄거리</th>
								<th>방송시작일</th>
								<th>방송종료일</th>
								<th>포스터URL</th>
								<th>노출여부</th>
							</tr>
						</thead>
						<tr>
							<td align="center"><input type="text" name="program_id" /></td>
							<td align="center"><input type="text" name="program_name" /></td>
							<td align="center">
								<select name="type">
									<option value="드라마">드라마</option>
									<option value="예능">예능</option>
								</select>								
							</td>
							<td align="center"><input type="text" name="priority" /></td>
							<td align="center"><input type="text" name="story" /></td>
							<td align="center"><input type="text" name="start_dt" /></td>
							<td align="center"><input type="text" name="end_dt" /></td>
							<td align="center"><input type="text" name="photo_url" /></td>
							<td align="center">
								<select name="use_yn">
									<option value="Y">Y</option>
									<option value="N">N</option>
								</select>			
							</td>					
						</tr>
					</table>
					<input type="submit" value="수정완료" />
				</fieldset>
			</form>	
		</div>
	</div>
	<!--// Contents -->
	
	<!-- Footer -->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/footer.php'; ?>
	<!--// Footer -->
</div>
</body>
</html>